package book;//包：为了更好地管理类，如book里面全放跟书有关的类

//book-书籍对象
public class Book {
    private String name;//书籍名称//private 体现封装性
    private String author;//作者
    private double price;//价格
    private String type;//类型
    private  boolean isBorrowed;//是否被借出//isBorrowed不需要构造函数来将它赋初值，因为它默认就是flase未借出

    //所有的构造方法 get set tostring-自动生成
    public Book(String name, String author, double price, String type) {
        this.name = name;
        this.author = author;
        this.price = price;
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public String getAuthor() {
        return author;
    }

    public double getPrice() {
        return price;
    }

    public String getType() {
        return type;
    }

    public boolean isBorrowed() {
        return isBorrowed;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public void setPrice(int place) {
        this.price = place;
    }

    public void setType(String type) {
        this.type = type;
    }

    public void setBorrowed(boolean borrowed) {
        isBorrowed = borrowed;
    }

    @Override
    public String toString() {
        return "Book{" +
                "name='" + name + '\'' +
                ", author='" + author + '\'' +
                ", place=" + price +
                ", type='" + type + '\'' +
                ", "+
                (isBorrowed==true?"已被借出":"未被借出") +
                '}';
    }//三目运算符

}
